#include<bits/stdc++.h>
using namespace std;
int ma[20010][20010],ans2=100010,m,n;
bool choose[100010];
void fun(int k,int ans1){
    bool flag=0,f=0;
    if(k<=n){
        for(int i=1;i<=m;i++){
            if(ma[k][i]&&choose[i]){flag=1;break;}
        }
        if(flag==0){
            for(int i=1;i<=m;i++){
                if(ma[k][i]&&choose[i]==0){
                    choose[i]=1,ans1++,f=1;
                    fun(k+1,ans1);
                    choose[i]=0,ans1--;
                }
            }
        }
        if(f==0) fun(k+1,ans1);
    }
    else{
        ans2=min(ans2,ans1);
        return;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int p=1;p<=T;p++){
        ans2=0;
        for(int i=1;i<=20010;i++){
            for(int j=1;j<=20010;j++){
                ma[i][j]=0;
            }
        }
        for(int i=1;i<=100010;i++) choose[i]=0;
        int l,v,di[100010],vi[100010],ai[100010],pj[100010],ans=0;
        double vp;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++) cin>>di[i]>>vi[i]>>ai[i];
        for(int i=1;i<=m;i++) cin>>pj[i];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                int x=pj[j]-di[i];
                if(x>=0&&(ai[i]>=0||x<=vi[i]*vi[i]/(-2*ai[i]))){
                    vp=sqrt(2*ai[i]*x+vi[i]*vi[i]);
                    if(vp>v){ma[i][j]=1,ans++;break;}
                }
            }
       }
        fun(1,0);
        cout<<ans<<' '<<0<<endl;
    }
    return 0;
}
